package design_mode.策略模式;

import java.util.*;

import java.util.AbstractList;

public class PrintLn {

    public static void main(String[] args) {

        double price = 0d;  // 单价
        int num = 0;  // 数量
        double totalPrices = 0d; // 商品合计费用
        double total = 0d;  // 总消费
        List<Double> totalPricesList = new ArrayList<Double>();  // 消费清单
        Scanner sc = new Scanner(System.in);
        do {
            System.out.println("请输入商品单价：");
            price = Double.parseDouble(sc.nextLine());
            System.out.println("请输入商品数量：");
            num = Integer.parseInt(sc.nextLine());
            // 打折
            totalPrices = CashFactory.cashSuper(2).acceptCash(price, num);
            CashContext cc = new CashContext(2);
            totalPrices = cc.getResult(price, num);
            totalPricesList.add(totalPrices);
            total = total + totalPrices;
        } while (
                price > 0 && num > 0
        );
        System.out.printf("总计：%s元\n", total);
        System.out.printf("清单：%s元", totalPricesList);
    }
}
